home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / Install_3.3 / ARexx / Install_Startup.dopus5 < prev    next >
Text File  |  1997-05-09  |  9KB  |  377 lines

  1. /* $VER: Install_Startup.dopus5 3.1 (09.05.97) © Frédéric Steinfels
  2. */
  3.  
  4. signal on BREAK_C
  5. signal on BREAK_D
  6. signal on BREAK_E
  7. signal on BREAK_F
  8. signal on HALT
  9. signal on IOERR
  10. signal on SYNTAX
  11. signal on FAILURE
  12. options failat 21
  13. options results
  14. parse arg arguments
  15.  
  16. Call Init
  17. address value PORT
  18.  
  19. MYPORT='DOINST.'
  20. prgcnt=1
  21. do while POS(MYPORT||prgcnt,SHOW('p'))~=0
  22.     prgcnt=prgcnt+1
  23. end
  24. MYPORT=MYPORT||prgcnt
  25. MYPORTH=openport(MYPORT)
  26. MNPORT='DOINMN.'||prgcnt
  27. SSPORT='DOINSS.'||prgcnt
  28. SDPORT='DOINSD.'||prgcnt
  29. VSPORT='DOINVS.'||prgcnt
  30. VDPORT='DOINVD.'||prgcnt
  31. RQPORT='DOINRQ.'||prgcnt
  32. EXPORT='DOINEX.'||prgcnt
  33.  
  34. say GetCatStr(20,'Version Installation Program for Directory Opus Magellan')
  35. say GetCatStr(21,'Written by Frederic Steinfels, fsteinfe@iiic.ethz.ch')
  36.  
  37. Call CheckDate
  38.  
  39. srch=SOURCEHANDLE
  40. if srch=0 THEN DO
  41.     dopus request '"' || GetCatStr(22,'No source lister') || '"' GetCatStr(0,'Abort')
  42.     call CleanUP
  43.     exit
  44. end
  45. dsth=DESTINATIONHANDLE
  46. if (dsth=srch | dsth=0) & (symbol('DESTINATION')='LIT') THEN do
  47.     dopus request '"' || GetCatStr(23,'No destination lister') || '"' GetCatStr(0,'Abort')
  48.     call CleanUP
  49.     exit
  50. end
  51.  
  52. lister query srch path
  53. srcp=result
  54. if ~exists(srcp) | symbol('result')='LIT' then do
  55.     dopus request '"' || GetCatStr(24,'Source path not valid') || '"' GetCatStr(0,'Abort')
  56.     call CleanUP
  57.     exit
  58. end
  59. if symbol('DESTINATION')='LIT' then do
  60.     lister query dsth path
  61.     dstp=result
  62.     if ~exists(dstp) | symbol('result')='LIT' then do
  63.         dopus request '"' || GetCatStr(25,'Destination path not valid') || '"' GetCatStr(0,'Abort')
  64.         call CleanUP
  65.         exit
  66.     end
  67. end
  68. else do
  69.     dsth=srch
  70.     dstp=DESTINATION
  71. end
  72.  
  73. dstp=AbsolutePath(dstp)
  74. srcp=AbsolutePath(srcp)
  75.  
  76. if UPPER(dstp)=UPPER(srcp) then do
  77.     dopus request '"' || GetCatStr(26,'Destination must be different to source') || '"' GetCatStr(0,'Abort')
  78.     call CleanUP
  79.     exit
  80. end
  81.  
  82. lister query srch numselentries
  83. if symbol('result')='LIT' then result=0
  84. nums=result
  85. lister query dsth numselentries
  86. if symbol('result')='LIT' then result=0
  87. numd=result
  88. if nums=0 & numd=0 & SYMBOL('FILE')='LIT' then do
  89.     dopus request '"' || GetCatStr(27,'Nothing selected') || '"' GetCatStr(0,'Abort')
  90.     call CleanUP
  91.     exit
  92. end
  93.  
  94. lister query srch position
  95. parse var result x "/" y "/" w "/" h " " .
  96. lister new x"/"y"/"w"/"h
  97. nsrch=result
  98. lister wait nsrch quick
  99. lister set nsrch visible 0
  100. lister read nsrch '"' || srcp || '"' force
  101. lister set nsrch mode name
  102. lister set nsrch off
  103. lister set nsrch lock state on format on
  104. lister wait nsrch quick
  105. command source nsrch dest nsrch wait NONE
  106.  
  107. lister query dsth position
  108. parse var result x "/" y "/" w "/" h " " .
  109. lister new x"/"y"/"w"/"h
  110. ndsth=result
  111. lister wait ndsth quick
  112. lister set ndsth visible 0
  113. lister read ndsth '"' || dstp || '"' force
  114. lister wait ndsth quick
  115. lister set ndsth mode name
  116. lister set ndsth off
  117. lister set ndsth lock state on format on
  118. lister wait ndsth quick
  119. command source ndsth dest ndsth wait NONE
  120.  
  121. if symbol('FILE')='VAR' then do
  122.     lister select nsrch FILE 1
  123.     lister select ndsth FILE 1
  124. end
  125. else do
  126.     do while nums>0
  127.         lister query srch firstsel
  128.         dat=result
  129.         lister select srch dat 0
  130.         lister wait srch quick
  131.         lister select nsrch dat 1
  132.         lister wait nsrch quick
  133.         lister select ndsth dat 1
  134.         lister wait ndsth quick
  135.         nums=nums-1
  136.     end
  137. end
  138.  
  139. if symbol('DESTINATION')='LIT' then do
  140.     do while numd>0
  141.         lister query dsth firstsel
  142.         dat=result
  143.         lister select dsth dat 0
  144.         lister wait dsth quick
  145.         lister select ndsth dat 1
  146.         lister wait ndsth quick
  147.         lister select nsrch dat 1
  148.         lister wait nsrch quick
  149.         numd=numd-1
  150.     end
  151. end
  152.  
  153. lister refresh nsrch full
  154. lister refresh srch full
  155. lister refresh ndsth full
  156. lister refresh dsth full
  157.  
  158. address command 'resident c:version pure'
  159. address command 'resident c:delete pure'
  160. address REXX 'DOpus5:Arexx/Install_Main.dopus5' PORT nsrch ndsth prgcnt '"' || PREFSFILE || '"'
  161.  
  162. Call CleanUP
  163. address command 'ask "' || GetCatStr(28,'Press enter, return or close button to continue.') || '"'
  164. exit
  165.  
  166.  
  167. CleanUp:
  168. Call WriteCh('CON',GetCatStr(56,'Waiting for subtasks') || ' ')
  169. do while POS(MNPORT,SHOW('p'))~=0 | POS(SSPORT,SHOW('p'))~=0 | POS(SDPORT,SHOW('p'))~=0 | POS(VSPORT,SHOW('p'))~=0 | POS(VDPORT,SHOW('p'))~=0 | POS(RQPORT,SHOW('p'))~=0 | POS(EXPORT,SHOW('p'))~=0
  170.     Call WriteCh('CON','.')
  171.     Call Delay(25)
  172. end
  173. if symbol('nsrch') = 'VAR' then do
  174.     lister close nsrch
  175. end
  176. if symbol('ndsth') = 'VAR' then do
  177.     lister close ndsth
  178. end
  179. Call WriteLn('CON',' ' || GetCatStr(58,'finished'))
  180. if POS(MYPORT,SHOW('p'))~=0 then do
  181.     Call FORBID()
  182.     Call ClosePort(MYPORTH)
  183.     Call PERMIT()
  184. end
  185. call CloseCatalog(catalog)
  186. Call Close('CON')
  187. return
  188.  
  189.  
  190.  
  191. ERROR:
  192. HALT:
  193. IOERR:
  194. SYNTAX:
  195. IF RC ~= 0 THEN DO
  196.  line=sigl
  197.  text=errortext(rc)
  198.  dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || text || lf || GetCatStr(19,'Line') line || '"' GetCatStr(0,'Abort')
  199. END
  200. else do
  201.  dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || '"' GetCatStr(0,'Abort')
  202. end
  203. BREAK_C:
  204. BREAK_D:
  205. BREAK_E:
  206. BREAK_F:
  207. Call CleanUP
  208. exit
  209.  
  210.  
  211.  
  212. Init:
  213. libname = "rexxdossupport.library"
  214. if ~show("L", libname) then do
  215.   if ~addlib(libname, 0, -30, 2) then do
  216.     say libname "not added!"
  217.     exit
  218.   end
  219. end
  220. libname = "rexxtricks.library"
  221. if ~show("L", libname) then do
  222.   if ~addlib(libname, 0, -30) then do
  223.     say libname "not added!"
  224.     exit
  225.   end
  226. end
  227. libname = "rexxsupport.library"
  228. if ~show("L", libname) then do
  229.   if ~addlib(libname, 0, -30) then do
  230.     say libname "not added!"
  231.     exit
  232.   end
  233. end
  234. libname = "locale.library"
  235. if ~show("L", libname) then do
  236.   if ~addlib(libname, 0, -30) then do
  237.     say libname "not added!"
  238.     exit
  239.   end
  240. end
  241. ProgramName = "Install_Startup.dopus5";
  242. ArgsTemplate = "PORT/A,SOURCEHANDLE/A,DESTINATIONHANDLE/A,PREFSFILE/A,FILE,DESTINATION"
  243. lf='0a'x
  244. if strip(arguments) = '?' then do
  245.     Call WriteCh(STDOUT, ArgsTemplate || ': ')
  246. pull arguments
  247. end; else nop
  248. if ~ReadArgs(arguments,ArgsTemplate) then do
  249.     say Fault(RC,ProgramName)
  250.      exit 10
  251. end; else nop
  252. drop arguments
  253. inlocpr='DOpus5:System/Install_Locale.prefs'
  254. catalog=opencatalog('Install.dopus5.catalog','english',0)
  255. if ~open('CON','CONSOLE:','WRITE') then do
  256.     dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || GetCatStr(15,'Unable to open') 'CONSOLE:' || '"' GetCatStr(0,'Abort')
  257.     call CleanUP
  258.     Exit
  259. end
  260. return
  261.  
  262.  
  263. CheckDate:
  264. if exists(inlocpr) then do
  265.     if ~open(lp,inlocpr,'READ') then do
  266.         dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || GetCatStr(15,'Unable to open') inlocpr || '"' GetCatStr(0,'Abort')
  267.         Call CleanUP
  268.         exit
  269.     end
  270.     crc1=readln(lp)
  271.     Call Close(lp)
  272.     if exists('ENV:Sys/locale.prefs') then do
  273.         crc2=crc32('ENV:Sys/locale.prefs')
  274.     end
  275.     else do
  276.         crc2=0
  277.     end
  278.     if crc2~=crc1 then do
  279.         call UpdateDate
  280.     end
  281.     return
  282. end
  283. call UpdateDate
  284. return
  285.  
  286.  
  287.  
  288. UpdateDate:
  289. day=13
  290. month=1
  291. year=114
  292.  
  293. tr.0='.'
  294. tr.1='-'
  295. tr.2='/'
  296. tr.3=' '
  297.  
  298. if ~open(lp,inlocpr,'WRITE') then do
  299.     dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || GetCatStr(29,'Please start me later again.' || lf || 'Date Format update routine' || lf || 'cant be started twice.') || '"' GetCatStr(0,'Abort')
  300.     call CleanUP
  301.     exit
  302. end
  303. if exists('ENV:Sys/locale.prefs') then do
  304.     Call WriteLn(lp,crc32('ENV:Sys/locale.prefs'))
  305. end
  306. else do
  307.     Call WriteLn(lp,0)
  308. end
  309.  
  310. do while month < 13
  311.     address command 'echo >T:VERTEST "$VER: x 0.0 (' || day || '.' || copies(0,2-length(month)) || month || '.' || year || ')"'
  312.     address command 'version >T:VERRES T:VERTEST FULL'
  313.     if open(ver,'T:VERRES','read') then do
  314.         ln=readln(ver)
  315.         Call Close(ver)
  316.         parse var ln '(' ln ')'
  317.         d.month.0=LENGTH(ln)
  318.         Call WriteLn(lp,d.month.0)
  319.         z=copies(' ',d.month.0)
  320.         cnt=0
  321.         d.tr=''
  322.         d.month.1=0
  323.         d.month.2=0
  324.         do until symbol('tr.cnt')='LIT'
  325.             if (length(ln)-2)=length(compress(ln,tr.cnt)) then do
  326.                 d.month.1=POS(tr.cnt,ln)
  327.                 z=OVERLAY('.',z,d.month.1,1)
  328.                 d.month.2=POS(tr.cnt,ln,d.month.1+1)
  329.                 z=OVERLAY('.',z,d.month.2,1)
  330.                 d.tr=tr.cnt
  331.             end
  332.             cnt=cnt+1
  333.         end
  334.         Call WriteLn(lp,d.month.1)
  335.         Call WriteLn(lp,d.month.2)
  336.         d.month.3=POS(day,ln)
  337.         Call WriteLn(lp,d.month.3)
  338.         z=OVERLAY('..',z,d.month.3,2)
  339.         d.month.4=POS(year//100,ln)
  340.         Call WriteLn(lp,d.month.4)
  341.         z=OVERLAY('..',z,d.month.4,2)
  342.         d.month.5=POS(19+year%100,ln)
  343.         Call WriteLn(lp,d.month.5)
  344.         if d.month.5~=0 then do
  345.             z=OVERLAY('..',z,d.month.5,2)
  346.         end
  347.         d.month.6=POS(' ',z)
  348.         Call WriteLn(lp,d.month.6)
  349.         d.month.7=LASTPOS(' ',z)-d.month.6+1
  350.         Call WriteLn(lp,d.month.7)
  351.         d.month.8=SUBSTR(ln,d.month.6,d.month.7)
  352.         Call WriteLn(lp,d.month.8)
  353.     end
  354.     else do
  355.         dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || GetCatStr(30,'Unable to open T:VERRES') || '"' GetCatStr(0,'Abort')
  356.         call CleanUP
  357.         exit
  358.     end    
  359.     month=month+1
  360. end
  361. Call WriteLn(lp,d.tr)
  362. Call Close(lp)
  363. delete('T:VERTEST')
  364. return
  365.  
  366.  
  367.  
  368. getcatstr: /* Thank you for this procedure, Edmund */
  369. parse arg msgno,msgstring
  370. if catalog~=0 then
  371.    msgstring=getcatalogstr(catalog,msgno,msgstring)
  372. do i=3 to arg()
  373.    parse var msgstring fore '%s' aft
  374.    msgstring=fore||arg(i)||aft
  375.    end
  376. return msgstring
  377.